home *** CD-ROM | disk | FTP | other *** search
/ Amiga Tools 5 / Amiga Tools 5.iso / tools / developer-tools / andere sprachen / gamesmaster / demosrc / fadingdemo.s < prev    next >
Text File  |  1996-07-16  |  5KB  |  156 lines

  1. ;Fade Demo
  2. ;---------
  3. ;There are three examples of fading in this program:  Fade_To_White,
  4. ;Fade_To_Palette, and Fade_To_Black.
  5. ;
  6. ;Press fire to see the end of the fade sequence.
  7.  
  8.     opt    o+
  9.  
  10.     INCLUDE    "exec/exec_lib.i"
  11.     INCLUDE    "games/games_lib.i"
  12.     INCLUDE    "games/games.i
  13.     INCLUDE    "games/gamesbase.i"
  14.  
  15. CALL    MACRO
  16.     jsr    _LVO\1(a6)
  17.     ENDM
  18.  
  19. LOCAL    =    1
  20.  
  21.     SECTION    "FadingDemo",CODE
  22.  
  23. ;===========================================================================;
  24. ;                             INITIALISE DEMO
  25. ;===========================================================================;
  26.  
  27. Start:    MOVEM.L    A0-A6/D1-D7,-(SP)
  28.     move.l    ($4).w,a6
  29.     lea    GMS_Name(pc),a1
  30.     moveq    #$00,d0
  31.     CALL    OpenLibrary
  32.     move.l    d0,GMS_Base
  33.     beq    Quit
  34.  
  35.     move.l    GMS_Base(pc),a6
  36.     CALL    SetUserPri
  37.  
  38.     move.l    GMS_Base(pc),a6          ;Tell GMS that we want to add a
  39.     lea    ScreenStruct(pc),a0      ;screen for use.
  40.     CALL    Add_Screen
  41.     tst.l    d0
  42.     bne.s    Error
  43.  
  44.     move.l    SS_MemPtr1(a0),a1        ;Destination = SS_MemPtr1.
  45.     lea    PackedPicFile(pc),a0     ;File Name.
  46.     CALL    QuickLoad
  47.     tst.l    d0
  48.     beq.s    Error
  49.  
  50.     lea    ScreenStruct(pc),a0      ;Unpack the data on top of itself.
  51.     move.l    SS_MemPtr1(a0),a1
  52.     move.l    a1,a0
  53.     moveq    #$00,d0
  54.     CALL    SmartUnpack
  55.  
  56.     lea    ScreenStruct(pc),a0      ;Now show the screen/pic.
  57.     CALL    Show_Screen
  58.  
  59. ;===========================================================================;
  60. ;                                MAIN CODE
  61. ;===========================================================================;
  62.  
  63.     moveq    #30,d0
  64.     CALL    Wait_Time
  65.  
  66. .Fade    CALL    Wait_VBL
  67.     CALL    Wait_OSVBL
  68.     moveq    #00,d0                   ;d0 = Start at colour zero.
  69.     moveq    #16,d1                   ;d1 = Amount of colours (32)
  70.     lea    ScreenPalette(pc),a1
  71.     CALL    B12_FadeToPalette
  72.     tst.w    d0
  73.     bne.s    .Fade
  74.  
  75.     CALL    Wait_LMB
  76.  
  77. Fade_Here:                             ;This is the fade routine.  It will
  78. .Fade1    CALL    Wait_OSVBL               ;keep on looping until the fade is
  79.     moveq    #00,d0                   ;completely finished (ie all
  80.     moveq    #16,d1                   ;colours are white).  Notice the
  81.     CALL    B12_FadeToWhite          ;start colour is 00 and the amt of
  82.     tst.w    d0                       ;colours is 32, so that all the cols
  83.     bne.s    .Fade1                   ;are included in the range.
  84.  
  85.     moveq    #30,d0
  86.     CALL    Wait_Time
  87.                                  ;Now we fade down to black. Note
  88. .Fade2    CALL    Wait_OSVBL               ;that we have calld Initialise_Fader
  89.     CALL    B12_FadeToBlack          ;every time - otherwise each fade
  90.     tst.w    d0                       ;would not even attempt to start!
  91.     bne.s    .Fade2                   ;Also of interest is that Fading
  92.                                  ;to Black covers ALL colours.
  93.     moveq    #50,d0
  94.     CALL    Wait_Time
  95.  
  96. ;===========================================================================;
  97. ;                              RETURN TO DOS
  98. ;===========================================================================;
  99.  
  100.     CALL    Delete_Screen            ;Give back screen memory etc.
  101. Error    move.l    GMS_Base(pc),a1
  102.     move.l    ($4).w,a6
  103.     CALL    CloseLibrary
  104. Quit    MOVEM.L    (SP)+,A0-A6/D1-D7
  105.     moveq    #$00,d0
  106.     rts
  107.  
  108. ;===========================================================================;
  109. ;                                  DATA
  110. ;===========================================================================;
  111.  
  112. GMS_Name:
  113.     dc.b    "games.library",0
  114.     even
  115. GMS_Base:
  116.     dc.l    0
  117.  
  118. AMT_PLANES =    4
  119.  
  120. ScreenStruct:
  121.     dc.l    "GSV1"
  122.     dc.l    0,0,0                    ;Screen_Mem1/2/3
  123.     dc.l    0                        ;Screen link.
  124.     dc.l    0 ;ScreenPalette         ;Address of screen palette.
  125.     dc.l    0                        ;Address of rasterlist.
  126.     dc.l    16                       ;Amt of colours in palette.
  127.     dc.w    256,320,320/8            ;Screen Height, Width, Width/8
  128.     dc.w    256,320,320/8            ;Pic Height, Width, Width/8
  129.     dc.w    AMT_PLANES               ;Amt_Planes
  130.     dc.w    0,0                      ;Top Of Screen, X/Y
  131.     dc.w    0                        ;Scroll buffer in pixels/8.
  132.     dc.w    0,0                      ;X/Y counters (for scrolling).
  133.     dc.l    NOBURST                  ;Special attributes.
  134.     dc.w    LORES                    ;Screen mode.
  135.     dc.b    INTERLEAVED              ;Screen type
  136.     dc.b    0                        ;Screen Is Being Displayed?
  137.     dc.l    0,0                      ;Reserved area.
  138.     even
  139.  
  140. ScreenPalette:
  141.     dc.w    $0000,$0400,$0501,$0501,$0601,$0701,$0701,$0801
  142.     dc.w    $0901,$0A01,$0B02,$0432,$0CC0,$0F00,$0211,$0880
  143.  
  144. ;===========================================================================;
  145. ;                     PACKED DATA (OKAY FOR FASTRAM)
  146. ;===========================================================================;
  147.  
  148.  
  149. PackedPicFile:
  150.     IFNE    LOCAL
  151.     dc.b    "GAMESLIB:"
  152.     ENDC
  153.     dc.b    "data/Background16.pak",0
  154.     even
  155.  
  156.